Dynomotion

Group: DynoMotion Message: 5196 From: michaelthomasn Date: 6/12/2012
Subject: Workhead Spindle Setup
Tom,

I am trying to set up the spindle on this grinder. It is a dac output servo like the other axis', but there is no encoder.

It just turns on and runs at a specified rpm....there is no positioning.

I can get the spindle to turn with a move command in the console....but I want to have it turn on and off with the m commands and run to a particular rpm with the s command.

I have the axis configured as no input, dac output. I suspect that I should command movement with dac output.....but that does not work on the console screen.

Do I need to select user input?

I'm not sure what to do.

Mike
Group: DynoMotion Message: 5198 From: Tom Kerekes Date: 6/12/2012
Subject: Re: Workhead Spindle Setup
Hi Mike,
 
In this case there is no need to configure an axis since all we will be doing as commanding a DAC open loop.
 
Issuing DAC commands from the Console Screen should work.  If you have an axis enabled it will be continuously writing to the DAC so any Console DAC command will be immediately over written and will appear to not work.
 
After you figure out the relationship between DAC counts and RPM you can the modify the Spindle.c program to output the proper values.  To write to a DAC in C use something like:
 
DAC(4,speed*Factor);
 
Regards
TK

From: michaelthomasn <michaelniksch@...>
To: DynoMotion@yahoogroups.com
Sent: Tuesday, June 12, 2012 9:22 AM
Subject: [DynoMotion] Workhead Spindle Setup

 
Tom,

I am trying to set up the spindle on this grinder. It is a dac output servo like the other axis', but there is no encoder.

It just turns on and runs at a specified rpm....there is no positioning.

I can get the spindle to turn with a move command in the console....but I want to have it turn on and off with the m commands and run to a particular rpm with the s command.

I have the axis configured as no input, dac output. I suspect that I should command movement with dac output.....but that does not work on the console screen.

Do I need to select user input?

I'm not sure what to do.

Mike



Group: DynoMotion Message: 5200 From: michaelthomasn Date: 6/12/2012
Subject: Re: Workhead Spindle Setup
Tom,

I got the spindle going as you described from the console.

I have calculated my multiplication factor as 1.4655.

I don't understand the spindle.c, though.

#include "KMotionDef.h"

main()
{

float speed = *(float *)&persist.UserData[0]; // value stored is actually a float
printf("Spindle Set to %f\n",speed); // print the desired speed
}

It looks to me like speed is being defined as a non integer that is *(float *) multiplied by &persist.UserData[0].

What is the *(float *)? Is that the multiplication factor?

I am assuming that the &persist.UserData[0] is the value that will be entered from the S in kmotioncnc....but I really don't understand that, either.

Is * a multiplication sign?

Wow.....I'm lost here.

Mike




--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Mike,
>  
> In this case there is no need to configure an axis since all we will be doing as commanding a DAC open loop.
>  
> Issuing DAC commands from the Console Screen should work.  If you have an axis enabled it will be continuously writing to the DAC so any Console DAC command will be immediately over written and will appear to not work.
>  
> After you figure out the relationship between DAC counts and RPM you can the modify the Spindle.c program to output the proper values.  To write to a DAC in C use something like:
>  
> DAC(4,speed*Factor);
>  
> Regards
> TK
>
>
> ________________________________
> From: michaelthomasn <michaelniksch@...>
> To: DynoMotion@yahoogroups.com
> Sent: Tuesday, June 12, 2012 9:22 AM
> Subject: [DynoMotion] Workhead Spindle Setup
>
>
>
>  
>
> Tom,
>
> I am trying to set up the spindle on this grinder. It is a dac output servo like the other axis', but there is no encoder.
>
> It just turns on and runs at a specified rpm....there is no positioning.
>
> I can get the spindle to turn with a move command in the console....but I want to have it turn on and off with the m commands and run to a particular rpm with the s command.
>
> I have the axis configured as no input, dac output. I suspect that I should command movement with dac output.....but that does not work on the console screen.
>
> Do I need to select user input?
>
> I'm not sure what to do.
>
> Mike
>
Group: DynoMotion Message: 5201 From: michaelthomasn Date: 6/12/2012
Subject: Re: Workhead Spindle Setup
After more headbanging and research I seemed to notice that DAC(blah,blah); doesn't like anything but integers.

I came up with this.....and I'm prepared to hear that it's nonsense...lol.

#include "KMotionDef.h"

main()
{

float speed = *(float *)&persist.UserData[0]; // value stored is actually a float
printf("Spindle Set to %f\n",speed); // print the desired speed
int dacout = speed/1.4655;
DAC(2,dacout);
}

My DAC to rpm ratio is 1.4655.

I was able too find info on the persist,UserData[0].....so that question is answered.

Will this work if I set my var as 0 for the s program execute?

Mike

--- In DynoMotion@yahoogroups.com, "michaelthomasn" <michaelniksch@...> wrote:
>
> Tom,
>
> I am trying to set up the spindle on this grinder. It is a dac output servo like the other axis', but there is no encoder.
>
> It just turns on and runs at a specified rpm....there is no positioning.
>
> I can get the spindle to turn with a move command in the console....but I want to have it turn on and off with the m commands and run to a particular rpm with the s command.
>
> I have the axis configured as no input, dac output. I suspect that I should command movement with dac output.....but that does not work on the console screen.
>
> Do I need to select user input?
>
> I'm not sure what to do.
>
> Mike
>
Group: DynoMotion Message: 5203 From: Tom Kerekes Date: 6/12/2012
Subject: Re: Workhead Spindle Setup
Hi Mike,
 
You are the Master.
 
That looks good.  I'm not sure if you should divide or multiply by the 1.4655.
 
 
BTW the statement:
 
    float speed = *(float *)&persist.UserData[0]; // value stored is actually a float
 
is a fairly complex C statement.  It involves the concepts of "pointers", "casting", and "dereferencing".  It is tricky because the UserData variables are defined as 32-bit integers but KMotionCNC wants to download a 32-bit floating point number as the speed (123.4 RPM).  KMotionCNC puts the floating point speed into the memory of persist.UserData[0].
 
The "&" operator creates a "pointer" to the variable.  A pointer is basically the address of the thing rather than the thing itself.
 
(  ) before something does a "cast" which changes the type of a thing
 
float * is a type of pointer to a float
 
(float *) does a cast of the pointer to an integer to a pointer to a float
 
* is the dereference operator.  It instructs to get the thing that the pointer is pointing at.
 
So in English the statement says:  Take the address of where KMotionCNC put the Speed, treat it as an address of a float, go and get the float at that address, store it into the floating point variable called "speed". 
 
Simple right?
 
TK
From: michaelthomasn <michaelniksch@...>
To: DynoMotion@yahoogroups.com
Sent: Tuesday, June 12, 2012 3:13 PM
Subject: [DynoMotion] Re: Workhead Spindle Setup

 
After more headbanging and research I seemed to notice that DAC(blah,blah); doesn't like anything but integers.

I came up with this.....and I'm prepared to hear that it's nonsense...lol.

#include "KMotionDef.h"

main()
{

float speed = *(float *)&persist.UserData[0]; // value stored is actually a float
printf("Spindle Set to %f\n",speed); // print the desired speed
int dacout = speed/1.4655;
DAC(2,dacout);
}

My DAC to rpm ratio is 1.4655.

I was able too find info on the persist,UserData[0].....so that question is answered.

Will this work if I set my var as 0 for the s program execute?

Mike

--- In DynoMotion@yahoogroups.com, "michaelthomasn" <michaelniksch@...> wrote:
>
> Tom,
>
> I am trying to set up the spindle on this grinder. It is a dac output servo like the other axis', but there is no encoder.
>
> It just turns on and runs at a specified rpm....there is no positioning.
>
> I can get the spindle to turn with a move command in the console....but I want to have it turn on and off with the m commands and run to a particular rpm with the s command.
>
> I have the axis configured as no input, dac output. I suspect that I should command movement with dac output.....but that does not work on the console screen.
>
> Do I need to select user input?
>
> I'm not sure what to do.
>
> Mike
>



Group: DynoMotion Message: 5204 From: Michael Niksch Date: 6/12/2012
Subject: Re: Workhead Spindle Setup
Ya....very simple....lol.

Thanks for the explanation.  Only a little bit sinks in at a time. :-)

Mike



On Jun 12, 2012, at 5:57 PM, Tom Kerekes <tk@...> wrote:

 

Hi Mike,
 
You are the Master.
 
That looks good.  I'm not sure if you should divide or multiply by the 1.4655.
 
 
BTW the statement:
 
    float speed = *(float *)&persist.UserData[0]; // value stored is actually a float
 
is a fairly complex C statement.  It involves the concepts of "pointers", "casting", and "dereferencing".  It is tricky because the UserData variables are defined as 32-bit integers but KMotionCNC wants to download a 32-bit floating point number as the speed (123.4 RPM).  KMotionCNC puts the floating point speed into the memory of persist.UserData[0].
 
The "&" operator creates a "pointer" to the variable.  A pointer is basically the address of the thing rather than the thing itself.
 
(  ) before something does a "cast" which changes the type of a thing
 
float * is a type of pointer to a float
 
(float *) does a cast of the pointer to an integer to a pointer to a float
 
* is the dereference operator.  It instructs to get the thing that the pointer is pointing at.
 
So in English the statement says:  Take the address of where KMotionCNC put the Speed, treat it as an address of a float, go and get the float at that address, store it into the floating point variable called "speed". 
 
Simple right?
 
TK
From: michaelthomasn <michaelniksch@...>
To: DynoMotion@yahoogroups.com
Sent: Tuesday, June 12, 2012 3:13 PM
Subject: [DynoMotion] Re: Workhead Spindle Setup

 
After more headbanging and research I seemed to notice that DAC(blah,blah); doesn't like anything but integers.

I came up with this.....and I'm prepared to hear that it's nonsense...lol.

#include "KMotionDef.h"

main()
{

float speed = *(float *)&persist.UserData[0]; // value stored is actually a float
printf("Spindle Set to %f\n",speed); // print the desired speed
int dacout = speed/1.4655;
DAC(2,dacout);
}

My DAC to rpm ratio is 1.4655.

I was able too find info on the persist,UserData[0].....so that question is answered.

Will this work if I set my var as 0 for the s program execute?

Mike

--- In DynoMotion@yahoogroups.com, "michaelthomasn" <michaelniksch@...> wrote:
>
> Tom,
>
> I am trying to set up the spindle on this grinder. It is a dac output servo like the other axis', but there is no encoder.
>
> It just turns on and runs at a specified rpm....there is no positioning.
>
> I can get the spindle to turn with a move command in the console....but I want to have it turn on and off with the m commands and run to a particular rpm with the s command.
>
> I have the axis configured as no input, dac output. I suspect that I should command movement with dac output.....but that does not work on the console screen.
>
> Do I need to select user input?
>
> I'm not sure what to do.
>
> Mike
>